//------------------------------------------------------------------------------
// Fichiers d'ent�te utilis�s
//------------------------------------------------------------------------------
#include "GrayImage.hpp"
#include <math.h>
#include <GL/gl.h>
#include <iostream>

//------------------------------------------------------------------------------
// Définition de constantes
//------------------------------------------------------------------------------
namespace ImageAnalysis
{

	//----------------------------------------------------------------------
	// Constructeur
	//----------------------------------------------------------------------
	GrayImage::GrayImage( int width, int height ):
	Image(width, height)
	{
		//allocation de la structure contenant les pixels
		pixels = new unsigned char [width*height];
	}

	//----------------------------------------------------------------------
	// Destructeur
	//----------------------------------------------------------------------
	GrayImage::~GrayImage( )
	{
		delete pixels;
	}

    	//----------------------------------------------------------------------
	//
	//----------------------------------------------------------------------
	void GrayImage::Draw( )
	{
        glDrawPixels( layerWidth, layerHeight, GL_LUMINANCE, GL_UNSIGNED_BYTE, pixels );
	}

    	//----------------------------------------------------------------------
	//
	//----------------------------------------------------------------------
	unsigned char* GrayImage::GetPixel( int index )
	{
		return &pixels[index];
	}

    	//----------------------------------------------------------------------
	//
	//----------------------------------------------------------------------
	void GrayImage::SetPixel( int index, unsigned char* value )
	{
		pixels[index]=*value;
	}
}

